
const listeners = new Map();

export const eventBus = {
  $on(event, callback) {
    if (!listeners.has(event)) listeners.set(event, new Set());
    listeners.get(event).add(callback);
    uni.$on(event, callback);
	console.log('111111111111:',listeners.has(event),this.list());
  },
  $off(event, callback) {
    if (listeners.has(event)) {
      listeners.get(event).delete(callback);
      uni.$off(event, callback);
    }
  },
  list() {
    return Array.from(listeners.keys()); // 返回所有事件名
  }
};

